package com.example.demo.dto;

import java.util.Map;

public class CdcMessage {
    private Header header;
    private Map<String, Object> before;
    private Map<String, Object> after;
    private Metadata metadata;

    // getters and setters
    public Header getHeader() {
        return header;
    }

    public void setHeader(Header header) {
        this.header = header;
    }

    public Map<String, Object> getBefore() {
        return before;
    }

    public void setBefore(Map<String, Object> before) {
        this.before = before;
    }

    public Map<String, Object> getAfter() {
        return after;
    }

    public void setAfter(Map<String, Object> after) {
        this.after = after;
    }

    public Metadata getMetadata() {
        return metadata;
    }

    public void setMetadata(Metadata metadata) {
        this.metadata = metadata;
    }

    @Override
    public String toString() {
        return "CdcMessage{" +
                "header=" + header +
                ", before=" + before +
                ", after=" + after +
                ", metadata=" + metadata +
                '}';
    }

    // 内部类：Header
    public static class Header {
        private String messageId;
        private String timestamp;
        private String source;
        private String database;
        private String operation;
        private String transactionId;

        // getters and setters
        public String getMessageId() {
            return messageId;
        }

        public void setMessageId(String messageId) {
            this.messageId = messageId;
        }

        public String getTimestamp() {
            return timestamp;
        }

        public void setTimestamp(String timestamp) {
            this.timestamp = timestamp;
        }

        public String getSource() {
            return source;
        }

        public void setSource(String source) {
            this.source = source;
        }

        public String getDatabase() {
            return database;
        }

        public void setDatabase(String database) {
            this.database = database;
        }

        public String getOperation() {
            return operation;
        }

        public void setOperation(String operation) {
            this.operation = operation;
        }

        public String getTransactionId() {
            return transactionId;
        }

        public void setTransactionId(String transactionId) {
            this.transactionId = transactionId;
        }

        @Override
        public String toString() {
            return "Header{" +
                    "messageId='" + messageId + '\'' +
                    ", timestamp='" + timestamp + '\'' +
                    ", source='" + source + '\'' +
                    ", database='" + database + '\'' +
                    ", operation='" + operation + '\'' +
                    ", transactionId='" + transactionId + '\'' +
                    '}';
        }
    }

    // 内部类：Metadata
    public static class Metadata {
        private String table;
        private String[] primaryKey;
        private Long timestamp;
        private String lsn;
        private String position;

        // getters and setters
        public String getTable() {
            return table;
        }

        public void setTable(String table) {
            this.table = table;
        }

        public String[] getPrimaryKey() {
            return primaryKey;
        }

        public void setPrimaryKey(String[] primaryKey) {
            this.primaryKey = primaryKey;
        }

        public Long getTimestamp() {
            return timestamp;
        }

        public void setTimestamp(Long timestamp) {
            this.timestamp = timestamp;
        }

        public String getLsn() {
            return lsn;
        }

        public void setLsn(String lsn) {
            this.lsn = lsn;
        }

        public String getPosition() {
            return position;
        }

        public void setPosition(String position) {
            this.position = position;
        }

        @Override
        public String toString() {
            return "Metadata{" +
                    "table='" + table + '\'' +
                    ", primaryKey=" + java.util.Arrays.toString(primaryKey) +
                    ", timestamp=" + timestamp +
                    ", lsn='" + lsn + '\'' +
                    ", position='" + position + '\'' +
                    '}';
        }
    }
}    